const {getCart, delGoodsCart} = require('../../api/index')
Page({
  data: {
    cartData:[]
  },
  onLoad(options) {
    this.http()
  },
  onShow(){
    this.http()
  },
  delCartHandle(e){
      console.log('点击删除商品');
      console.log(e.currentTarget.dataset.id);
      delGoodsCart({currentID:e.currentTarget.dataset.id}).then(res => {
          if(res.data.status === 200){
              wx.showToast({
                title: '删除成功',
                duration:500
              })
              this.http()
          } else {
              wx.showToast({
                title: '删除失败',
              })
          }
      })
  },
  http(){
    getCart().then(res=>{
        console.log(res.data.data);
        this.setData({
            cartData:res.data.data
        })
    })
  }
})